<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content=" initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<title><#$shopinfo[0]['shopname']#></title>
<link rel="stylesheet" href="<#$Theme['P']['js']#>/jquerymobile/jquery.mobile-1.3.2.min.css">
<link rel="stylesheet" href="<#$Theme['T']['css']#>/login.css">
<script type="text/javascript" src="<#$Theme['P']['js']#>/jquery.js"></script>
<script type="text/javascript" src="<#$Theme['P']['js']#>/jquerymobile/jquery.mobile-1.3.2.min.js"></script>
<script type="text/javascript" src="<#$Theme['T']['js']#>/api.js"></script>
<title></title>

</head>
<body>
<include  file="public:head"/>

<div class="formbox">
<form name="regform">
<div class="tips" id="tips"></div>

    <label for="txt_user">手机号码:</label>
    <input type="tel" data-clear-btn="false" name="txt_user" id="txt_user" placeholder="输入手机号码" value="">
    
	
	<label for="password">验证码:</label>
	<div class="ugbox">
	
	<input type="tel" name="smscode" id="smscode" placeholder="输入验证码" autocomplete="off" maxlength="6" style="width:8em;">

	<div class="boxf1" style="padding:0 .5em;"><a href="#" data-role="button" id="btn_getcode">获取验证码</a></div>

  	</div>
  	<div class="tips" id="scode">
  		<div class="onSuccess" id="scodetext"></div>
  	</div>
	
	
	<a href="#" data-role="button" data-theme="a" id="btn_reg">登录</a>
	<a href="#" data-role="button" data-theme="c" id="btn_back">返回首页</a>

	</form>
</div>
<include file="public:foot"/>
<script>

	var bajax=false;
	var blive=false;
	var dcount=1*60;
	function ChangeLive(){
		dcount--;
		if(dcount<=0){
			if(blive){
				blive=false;
			}
		}else{
			setTimeout("ChangeLive()",1000);
		}
	}
	$(document).ready(function(){
		$("#btn_getcode").bind('click',function(){
			if(bajax){
				Tips("tips", "请耐心等待...", true, 1000);
				return false;
			}
			if(blive){
				Tips("tips", dcount+"秒后可以再试获取验证码", true, 1000);
				return false;
			}
			var u=$('#txt_user').val();
			if(u==""){
				Tips("tips", "请输入手机号码", true, 1000);
				/*
				$('#positionWindow').html('<p>请输入手机号码</p>');
				$('#positionWindow').popup('open');
				*/
				 return false;
			}
			bajax=true;
			dcount=1*60;
			$.ajax({
			  	url: '<#:U('userauth/smscode')#>',
		        type: "post",
				data:{
					'phone':u,
					},
				dataType:'json',
				error:function(){
					 Tips("tips", "服务器忙，请稍候再试", true, 1500);
					 bajax=false;
				},
				success:function(data){
					bajax=false;
					$('btn_getcode').button( "enable" );
					if(data.error==0){
						$('#scode').show();
						$('#scodetext').html('您的验证码是:'+data.msg);
						blive=true;
						setTimeout("ChangeLive()",1000);
						
					}else{
						Tips("tips", data.msg, true, 1500);
					}		
				}
			  });
		});
		$("#btn_reg").bind('click',function(){
			
			var u=$('#txt_user').val();
			var p=$('#smscode').val();
			if (u == "") {
			    Tips("tips", "请输入手机号码", true, 1000);
			    return false;
			}
			if (p == "") {
				  Tips("tips", "请填写验证码", true, 1000);
			        return false;
			}
			if(p.length!=6){
				Tips("tips", "验证码位数必须是6位", true, 1000);
			    return false;
			}
			  $.ajax({
			  	url: '<#:U('userauth/smslogin')#>',
		        type: "post",
				data:{
					'user':u,
					'smscode':p,
					'__hash__':$('input[name="__hash__"]').val()
					},
				dataType:'json',
				error:function(){
						 Tips("tips", "服务器忙，请稍候再试", true, 1500);
						},
				success:function(data){
						if(data.error==0){
							Tips("tips", "操作成功", false, 1500);
							setTimeout("goUrl('"+data.url+"')",1500);
						}else{
							Tips("tips", data.msg, true, 1500);
						}
				}
			});

		});
		$('#btn_back').bind('click',function(){
			history.go(-1);
		});
	});

	function goUrl(url){
		location.href=url;
	}
</script>
</body>
</html>